<?
include("includes/config.inc.php");
include("includes/auth.lib.php");
include("includes/image.class.php");
include("includes/upload.class.php");
include("includes/product_new.class.php");
$module="BANNER";
switch($lang) {
  case "ita":
	$currentlang = " - ITA";
  break;

  case "eng":
	$currentlang = " - ENG";
  break;

  case "fra":
	$currentlang = " - FRA";
  break;
}
if($_GET['num_per_page'] != "")  {
  $num_per_page = $_GET['num_per_page'];
  setcookie("num_per_page",$num_per_page,time() + $_CONFIG['expire']);
} elseif($_COOKIE['num_per_page'] != "")
     $num_per_page = $_COOKIE['num_per_page'];
  else  
    $num_per_page = 20;
   list($status, $user) = auth_get_status();
   switch($status){
       case AUTH_LOGGED:
        $result1 = @mysql_query("SELECT nome,stato FROM utenti WHERE id='$id_user';");
        list($username,$level) = mysql_fetch_row($result1);
	            //recupero i dati in post
               $op = $_GET['op'];
               if(!isset($op) && $op=="")
                 $op = $_POST['op'];
                $idbanner = $_GET['idbanner'];
               if(!isset($idbanner) || $idbanner=="")
                 $idbanner = $_POST['idbanner'];
			   $search = $_POST['search'];
			   $menusx = "<table width=200 cellpadding=3>
							<tr>
							  <td valign=middle width=30 height=30><a class=menusx href=banner.php?op=all_client><img src=\"imgs/ico_list.gif\" width=30 height=30 alt=\"Elenco Clienti\" border=0></a></td><td align=left valign=middle><a class=menusx href=banner.php?op=all_client>Elenco Clienti</a></td>
							</tr>
							<tr>
							   <td valign=middle width=30 height=30><a class=menusx href=banner.php?op=add_client><img src=\"imgs/ico_add.gif\" width=30 height=30 alt=\"Aggiungi Cliente\" border=0></a></td><td align=left valign=middle><a class=menusx href=banner.php?op=add_client>Aggiungi Cliente</a></td>
							  </tr>
							<tr>
							  <td valign=middle width=30 height=30><a class=menusx href=banner.php?op=all><img src=\"imgs/ico_list.gif\" width=30 height=30 alt=\"Elenco Banner\" border=0></a></td><td align=left valign=middle><a class=menusx href=banner.php?op=all>Elenco Banner</a></td>
							</tr>
							<tr>
							   <td valign=middle width=30 height=30><a class=menusx href=banner.php?op=add><img src=\"imgs/ico_add.gif\" width=30 height=30 alt=\"Aggiungi Banner\" border=0></a></td><td align=left valign=middle><a class=menusx href=banner.php?op=add>Aggiungi Banner</a></td>
							  </tr>
							<tr>
							 <td colspan=2>&nbsp;</td>
							</tr>
							<tr>
							 <td colspan=2>&nbsp;</td>
							</tr>
							<tr>
							  <td valign=middle width=30 height=30><a class=menusx href=gestione.php><img src=\"imgs/ico_back.gif\" width=30 height=30 alt=Principale border=0></a></td><td align=left valign=middle><a class=menusx href=gestione.php>Torna alla pagina principale</a></td>
							</tr>
							</table>";

############################################ opzioni possibili ###########################

            switch ($op)  {

############################################ Banner #######################################		  
			  case "all":
			  //recupero dati in GET
			            $min = $_GET['min'];
                        $max = $_GET['max'];
                        $page = $_GET['page'];
                     if (!isset($min))
                      $min= 0;
                     if (!isset($max))
                      $max = $num_per_page;
                     if (!isset($page))
                      $page = 1;
               $qry_tot = "SELECT idbanner FROM banner WHERE lang='$lang' AND sezione='piscine';";
               $r_tot = $conn->Execute($qry_tot);
               $qry = "SELECT idbanner FROM banner WHERE lang='$lang' AND sezione='piscine' ORDER BY posizione,ordine ASC LIMIT $min,$max;";
               $rs = $conn->Execute($qry);
               $num_user = $r_tot->RecordCount();
                 $content = "<table class=\"content\" width=\"100%\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\" border=1>\n"
                 ."<tr>
					<td colspan=8>Sono registrati <b>$num_user</b> banner.</td>
				 	</tr>
				 <tr>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b>Numero</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b>Posizione</b></td>
				   <td class=\"tbtit\" align=\"\" width=\"10%\"><b>Ordine</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b>Cliente</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"20%\"><b>Scadenza</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b># Click</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b>Note</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"30%\"><b>Azioni</b></td>
				 </tr>";
			if($num_user > 0)  {
			     $i = $min + 1;	 
               while (!$rs->EOF)  {
			    $newBanner = new banner($rs->Fields("idbanner"));
				$idbanner = $newBanner->fields['idbanner'];
				$client = new bannerClient($newBanner->fields["idclient"]);
			   	if($newBanner->fields['attivo'] == "1")
				    $semaforo = "<a href=\"banner.php?op=disactive&idbanner=$idbanner\"><img src=\"imgs/ico_green.jpg\" border=0 alt=Disattiva></a>";
				   else
				    $semaforo = "<a href=\"banner.php?op=active&idbanner=$idbanner\"><img src=\"imgs/ico_red.jpg\" border=0 alt=Attiva></a>";
				  $azioni = "<a href=\"banner.php?op=mod&idbanner=$idbanner\"><img src=\"imgs/ico_edit.gif\" alt=\"modifica\" width=16 height=16 title=\"modifica\" border=\"0\"></a>&nbsp;&nbsp;
                  <a href=\"banner.php?op=delete&idbanner=$idbanner\" onclick='return confirm(\"Sei sicuro di voler eliminare questo Banner? \")'><img src=\"imgs/ico_delete.gif\" width=16 height=16 alt=\"cancella\" title=\"cancella\" border=\"0\"></a>&nbsp;&nbsp;".$semaforo;
				if(!is_null($newBanner->fields["endDate"]))  {
				  // scadenza a data
				  $scadenza = $newBanner->fields["endDate"];
				} else {
				   $scadenza = $newBanner->fields["imptotal"] - $newBanner->fields["impmade"]." impressions";
				} 
                 $content .= "<tr>
				  				<td class=\"tbtit\" align=\"center\" width=\"10%\"><b>$i</b></td>
				 				<td class=tdelenco align=center>".$newBanner->fields['sezione']."&nbsp;&nbsp;".$newBanner->fields['posizione']."</td>
								<td class=tdelenco align=center>".$newBanner->fields['ordine']."</td>
								<td class=tdelenco align=center>&nbsp;".$client->nome."</td>
								<td class=tdelenco align=center>&nbsp;$scadenza</td>
								<td class=tdelenco align=center>&nbsp;".$newBanner->fields['clicks']."</td>
								<td class=tdelenco align=center>&nbsp;".$newBanner->fields['note']."</td>
								<td align=\"center\" valign=\"middle\" class=tdelenco>
								 $azioni";
                 $content .= "</td>
				 </tr>\n";
				 $rs->MoveNext();
				 $i++;
               }
				 $rs->Close();
				 $r_tot->Close();
               //$content .= "</table>\n";
               //inizio paginazione
                     $content .= "<tr><td colspan=8><table class=\"tbtit\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\n";
                     $num_pages = ($num_user/$num_per_page) + 1;
                     $resto =  $num_user%$num_per_page;
                     if ($resto==0)
                      $num_pages--;
                     $content .= "<tr><td align=\"left\">";
                     if ($min!=0)   {
                      $min1 = $min-$num_per_page;
                      $max1 = $max-$num_per_page;
                      if ($page!=1)
                       $page1 = $page-1;;
                      $content .= "<a href=\"banner.php?op=all&min=$min1&max=$num_per_page&page=$page1\"><img src=\"imgs/precedente.gif\" border=\"0\" alt=\"precedente\"></a>&nbsp;&nbsp;&nbsp;";
                      }
                      $content .= "</td><td align=\"center\">
					  #&nbsp;<input type=text name=num_per_page value=\"$num_per_page\" onBlur=\"javascript:doReload(this.value);\" size=3 maxlength=3>&nbsp;&nbsp;";
                     for ($i=1;$i<=$num_pages;$i++)  {
                       if ($page!=$i)  {
                        $max1 = $i*$num_per_page;
                        $min1 = $max1 - $num_per_page;
                        $content .= "<a href=\"banner.php?op=all&min=$min1&max=$num_per_page&page=$i\"><b>$i</b></a>";
                        $content .= "  ";
                       }  else
                         $content .= "  $i  ";
                     }
                     $content .= "</td><td align=\"right\">";
                     $diff2 = $num_user - ($num_per_page*$page);
                     if ($diff2 > 0)   {
                      $min1 = $min + $num_per_page;
                      $max1 = $max + $num_per_page;
                      $page1 = $page + 1;
                      $content .= "&nbsp;&nbsp;&nbsp;<a href=\"banner.php?op=all&min=$min1&max=$num_per_page&page=$page1\"><img src=\"imgs/successivo.gif\" border=\"0\" alt=\"successivo\"></a>";
                     }
                     $content .= "</td></tr></table>\n";
					}
					 $content .= "</td></tr>
					 <tr>
					  <td colspan=8>&nbsp;</td>
					 </tr>
					 <tr>
					  <td colspan=8 align=center>
					   <table width=450 class=content cellpadding=2 bgcolor=#CCCCCC>
					    <form action=banner.php method=POST>
					    <tr>
						 <td width=200 align=right>Ricerca per cliente o posizione:</td>
						 <td width=150><input type=text name=search size=30></td>
						 <td><input type=hidden name=op value=search><input type=submit value=Cerca></td>
						</tr>
						</form>
					   </table>
					  </td>
					 </tr>
					 <tr>
					  <td colspan=8>&nbsp;</td>
					 </tr>
					 </table>\n";
			  break;	

              case "save":
			  		   $image = $_FILES['imageurl'];
					   $newBanner = new banner();
					   $error = $newBanner->save($_POST,$image);
					   if ($error == "0")  {
						Header("Location:banner.php?op=all");
					   }  else  {
						$content = printError($error);
					   }
              break;

              case "mod":
					  $newBanner = new banner($idbanner);
					  if($newBanner->fields["imageurl"] != "")  { 
					    if(substr($newBanner->fields["imageurl"],-3) == "swf")
						  $image = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="590" height="100">
                        <param name="movie" value="imgs_Banner/'.$newBanner->fields["idbanner"].'/'.$newBanner->fields["imageurl"].'">
                        <param name="quality" value="high">
                        <embed src="imgs_Banner/'.$newBanner->fields["idbanner"].'/'.$newBanner->fields["imageurl"].'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="590" height="100"></embed>
				 </object>';
						else  
					      $image = "<div align=center><img src=\"imgs_Banner/".$newBanner->fields["idbanner"]."/".$newBanner->fields["imageurl"]."\"></div>";
					  }
					  if($newBanner->fields['imptotal'] != "0")  {
					    //impressions
						$check1 = " checked";
						$check2 = "";
						$dis1 = "";
						$dis2 = " disabled=true";
						$dis3 = " disabled=true";
						$date1 = "";
						$date2 = "";
						$onclick1 = "";
						$onclick2 = "";
					  } else {
					    //scadenza
						$check1 = "";
						$check2 = " checked";
						$dis1 = " disabled=true";
						$dis2 = "";
						$dis3 = "";
						$date1 = $newBanner->fields['startDate'];
						$date2 = $newBanner->fields['endDate'];
						$onclick1 = "javascript:showCalendar('date1','%d/%m/%Y')";
						$onclick2 = "javascript:showCalendar('date2','%d/%m/%Y')";
					  }
				     $content = "<table width=100% cellpadding=3 cellspacing=0 class=content border=\"1 solid #COCOCO\">
				   			<form name=\"insertbanner\" action=\"banner.php\" method=\"POST\" enctype=\"multipart/form-data\">
				   	<tr><td align=\"center\" class=tbtit colspan=2><b>Modifica Banner</b></td></tr>
                   <tr>
				    <td align=right><b>Cliente:</b></td><td>";
					  //select cliente
					  $sql = "SELECT nome,idclient FROM banner_client ORDER BY nome;";
					  $rsmenu = $conn->Execute($sql);
					  $content .= $rsmenu->GetMenu2("idclient",$newBanner->fields['idclient'],false);
					  $rsmenu->Close();
					$content .= "</td>
					</tr>
                    <tr>
				    <td align=right><b>Sezione o pagina:</b></td><td>
					 <select name=sezione>
					  <option value=piscine"; if($newBanner->fields['sezione'] == "piscine") $content .= " selected"; $content .= ">Piscine</option>
					 </select>
					</td>
					</tr>
                    <tr>
				    <td align=right><b>Posizione:</b></td><td>
					 <select name=posizione>
					  <option value=\"\">Seleziona..</option>
					  <option value=alto"; if($newBanner->fields['posizione'] == "alto") $content .= " selected"; $content .= ">alto</option>
					  <option value=destra"; if($newBanner->fields['posizione'] == "destra") $content .= " selected"; $content .= ">destra</option>
					  <option value=basso"; if($newBanner->fields['posizione'] == "basso") $content .= " selected"; $content .= ">basso</option>
					  <option value=sinistra"; if($newBanner->fields['posizione'] == "sinistra") $content .= " selected"; $content .= ">sinistra</option>
					 </select>
					</td>
					</tr>
					<tr>
				    	<td align=right><b>Ordine:</b></td><td>
							<input type=\"text\" name=ordine size=10 value=\"".$newBanner->fields['ordine']."\" />
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Note:</b></td><td>
							<textarea name=\"note\" cols=\"50\" rows=\"5\">".$newBanner->fields['note']."</textarea>
						</td>
					</tr>
					
					<tr>
				    	<td align=right><b>Tag Title:</b></td><td>
							<input type=\"text\" name=\"titletag\" size=100 value=\"".$newBanner->fields['titletag']."\" />
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Tag Description:</b></td><td>
							<textarea name=\"desctag\" cols=\"50\" rows=\"5\">".$newBanner->fields['desctag']."</textarea>
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Tag H1:</b></td><td>
							<input type=\"text\" name=\"h1tag\" size=100 value=\"".$newBanner->fields['h1tag']."\" />
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Testo descrittivo:</b></td><td>
							<textarea name=\"testoDescrittivo\" cols=\"80\" rows=\"5\">".$newBanner->fields['testoDescrittivo']."</textarea>
						</td>
					</tr>
					
					<tr>
					 <td align=right><b>Seleziona la scadenza:</b></td>
					 <td valign=top>
					 <table width=100% class=content cellpadding=2>
					  <tr>
					   <td width=20 align=center><input type=radio name=sel_scadenza value=imp onClick=\"doSwitchScadenza(this);\" $check1></td>
					   <td>Impressions:&nbsp;<input type=text name=imptotal size=5 value=\"".$newBanner->fields['imptotal']."\" $dis1></td>
					  </tr>
					  <tr>
					   <td width=20 align=center><input type=radio name=sel_scadenza value=date onClick=\"doSwitchScadenza(this);\" $check2></td>
					   <td>Data inizio:&nbsp;<input type=text id=data1 name=startDate size=10 onBlur=\"check_date(this)\" value=\"$date1\" $value1 $dis2><a id=link1 href=\"javascript:;\" onclick=\"$onclick1\"><img src=\"imgs/date.gif\" border=\"0\" width=20 height=18 alt=\"Seleziona una data\"></a></td>
					  </tr>
					  <tr>
					   <td>&nbsp;</td>
					   <td>Data fine:&nbsp;&nbsp;&nbsp;<input type=text id=data2 name=endDate size=10 onBlur=\"check_date(this)\" value=\"$date2\" $dis3><a id=link2 href=\"javascript:;\" onclick=\"$onclick2\"><img src=\"imgs/date.gif\" border=\"0\" width=20 height=18 alt=\"Seleziona una data\"></a></td>
					  </tr>
					 </table>
					 </td>
				   </tr>
                   <tr>
				    <td align=right><b>Immagine o Flash:</b><br>
					Alto 680 x 270 px<br>
					</td><td valign=top><input type=\"file\" name=\"imageurl\" size=\"50\" /><br><br>
						$image
					</td>
					</tr>
                   <tr>
				    <td align=right><b>Link da cliccare:</b></td><td><input type=\"text\" name=\"clickurl\" size=\"30\" value=\"".$newBanner->fields['clickurl']."\"/></td>
					</tr>
                   <tr>
				    <td align=right><b>URL PROMOZIONE:</b></td><td><input type=\"text\" name=\"alttext\" size=\"30\" value=\"".$newBanner->fields['alttext']."\"/></td>
					</tr>
					<tr>
					  <td align=center colspan=2>
					   <input type=\"hidden\" name=\"op\" value=\"update\" />
					   <input type=\"hidden\" name=\"idbanner\" value=\"$idbanner\" />
                   	   <input type=\"image\" src=\"imgs/ico_save.gif\" title=\"Salva modifiche\"/ onclick=\"return control_banner();\"> - <a href=\"javascript:document.insertbanner.submit();\" onclick=\"return control_banner();\">Salva modifiche</a></td></tr></form>
                   <tr>
				    <td align=right><b>Articoli in PROMOZIONE collegati:</b></td><td>
				    <div id=\"promozioni\">".$newBanner->getPromozioni(2)."</div>
				    </td>
					</tr>
				   </table>";
              break;

              case "update":
			  	   $image = $_FILES['imageurl'];
				   $newBanner = new banner($idbanner);
				   $error = $newBanner->update($_POST,$image);
				   $content = printError($error,"banner.php?op=all");
              break;

              case "delete":
				   $newBanner = new banner($idbanner);
				   $error = $newBanner->delete();
				   $content = printError($error,"banner.php?op=all");
              break;

              case "add":
				     $content = "<table width=100% cellpadding=3 cellspacing=0 class=content border=\"1 solid #COCOCO\">
				   			<form name=\"insertbanner\" action=\"banner.php\" method=\"POST\" enctype=\"multipart/form-data\">
				   	<tr><td align=\"center\" class=tbtit colspan=2><b>Aggiungi Banner</b></td></tr>
                   <tr>
				    <td align=right><b>Seleziona il cliente:</b></td><td>";
					  //select provincia
					  $sql = "SELECT nome,idclient FROM banner_client ORDER BY nome;";
					  $rsmenu = $conn->Execute($sql);
					  $content .= $rsmenu->GetMenu("idclient",'',false);
					  $rsmenu->Close();
					$content .= "</td>
					</tr>
                    <tr>
				    <td align=right><b>Sezione o pagina:</b></td><td>
					 <select name=sezione>
					  <option value=piscine>Piscine</option>
					 </select>
					</td>
					</tr>
                    <tr>
				    <td align=right><b>Posizione:</b></td><td>
					 <select name=posizione>
					  <option value=\"\">Seleziona..</option>
					  <option value=alto>alto</option>
					  <option value=destra>destra</option>
					  <option value=basso>basso</option>
					  <option value=sinistra>sinistra</option>
					 </select>
					</td>
					</tr>
					<tr>
				    	<td align=right><b>Ordine:</b></td><td>
							<input type=\"text\" name=ordine size=10 value=\"\" />
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Note:</b></td><td>
							<textarea name=\"note\" cols=\"50\" rows=\"5\"></textarea>
						</td>
					</tr>
					
					<tr>
				    	<td align=right><b>Tag Title:</b></td><td>
							<input type=\"text\" name=\"titletag\" size=10 value=\"\" />
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Tag Description:</b></td><td>
							<textarea name=\"desctag\" cols=\"50\" rows=\"5\"></textarea>
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Tag H1:</b></td><td>
							<input type=\"text\" name=\"h1tag\" size=10 value=\"\" />
						</td>
					</tr>
					<tr>
				    	<td align=right><b>Testo descrittivo:</b></td><td>
							<textarea name=\"testoDescrittivo\" cols=\"80\" rows=\"5\"></textarea>
						</td>
					</tr>
					
					<tr>
					 <td align=right><b>Seleziona la scadenza:</b></td>
					 <td valign=top>
					 <table width=100% class=content cellpadding=2>
					  <tr>
					   <td width=20 align=center><input type=radio name=sel_scadenza value=imp onClick=\"doSwitchScadenza(this);\" checked></td>
					   <td>Impressions:&nbsp;<input type=text name=imptotal size=5 value=0></td>
					  </tr>
					  <tr>
					   <td width=20 align=center><input type=radio name=sel_scadenza value=date onClick=\"doSwitchScadenza(this);\"></td>
					   <td>Data inizio:&nbsp;<input type=text id=data1 name=startDate size=10 onBlur=\"check_date(this)\" disabled=true><a id=link1 href=\"javascript:;\" onclick=\"\"><img src=\"imgs/date.gif\" border=\"0\" width=20 height=18 alt=\"Seleziona una data\"></a></td>
					  </tr>
					  <tr>
					   <td>&nbsp;</td>
					   <td>Data fine:&nbsp;&nbsp;&nbsp;<input type=text id=data2 name=endDate size=10 onBlur=\"check_date(this)\" disabled=true><a id=link2 href=\"javascript:;\" onclick=\"\"><img src=\"imgs/date.gif\" border=\"0\" width=20 height=18 alt=\"Seleziona una data\"></a></td>
					  </tr>
					 </table>
					 </td>
				   </tr>
                   <tr>
				    <td align=right><b>Immagine o Flash:</b><br>
					Alto 680 x 270 px<br>
					</td><td><input type=\"file\" name=\"imageurl\" size=\"50\" /></td>
					</tr>
                   <tr>
				    <td align=right><b>Link da cliccare:</b></td><td><input type=\"text\" name=\"clickurl\" size=\"30\" value=\"http://www.nomesito.it\"/></td>
					</tr>
                   <tr>
				    <td align=right><b>Testo alternativo:</b></td><td><input type=\"text\" name=\"alttext\" size=\"30\"/></td>
					</tr>
					<tr>
					  <td align=center colspan=2>
					   <input type=\"hidden\" name=\"op\" value=\"save\" />
                   	   <input type=\"image\" src=\"imgs/ico_save.gif\" title=\"Aggiungi\"/ onclick=\"return control_banner();\"> - <a href=\"javascript:document.insertbanner.submit();\" onclick=\"return control_banner();\">Salva</a></td></tr></form>
				   </table>";
              break;
			  
			  case "search":
			    $content = banner::search($search);
			  break;
			  			  			  			  
			  case "active":
				$newBanner = new banner($idbanner);
				$error = $newBanner->active();
				if($error == "0") {
				 header("Location:banner.php?op=all");
				 die();
				} else  {
				  $content = $error;
				} 
			  break;
			  
			  case "disactive":
				$newBanner = new banner($idbanner);
				$error = $newBanner->disactive();
				if($error == "0")  {
				 header("Location:banner.php?op=all");
				 die(); 
				} else  {
				  $content = $error;
				} 
			  break;
			  
######################################## clienti ##############################################

			  case "all_client":
			  //recupero dati in GET
			            $min = $_GET['min'];
                        $max = $_GET['max'];
                        $page = $_GET['page'];
                     if (!isset($min))
                      $min= 0;
                     if (!isset($max))
                      $max = $num_per_page;
                     if (!isset($page))
                      $page = 1;
               $qry_tot = "SELECT idclient FROM banner_client WHERE lang='$lang';";
               $r_tot = $conn->Execute($qry_tot);
               $qry = "SELECT idclient FROM banner_client WHERE lang='$lang' ORDER BY nome ASC LIMIT $min,$max;";
               $rs = $conn->Execute($qry);
               $num_user = $r_tot->RecordCount();
                 $content = "<table class=\"content\" width=\"100%\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\" border=1>\n"
                 ."<tr>
					<td colspan=6>Sono registrati <b>$num_user</b> clienti.</td>
				 	</tr>
				 <tr>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b>Numero</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"20%\"><b>Nome</b></td>
				   <td class=\"tbtit\" align=\"\" width=\"20%\"><b>Contatto</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"20%\"><b>E-mail</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"10%\"><b>Telefono</b></td>
				   <td class=\"tbtit\" align=\"center\" width=\"20%\"><b>Azioni</b></td>
				 </tr>";
			if($num_user > 0)  {
			     $i = $min + 1;	 
               while (!$rs->EOF)  {
				 $client = new bannerClient($rs->Fields("idclient"));
				 $idclient = $client->idclient;
				 $azioni = "<a href=\"banner.php?op=mod_client&idclient=$idclient\"><img src=\"imgs/ico_edit.gif\" alt=\"modifica\" width=16 height=16 title=\"modifica\" border=\"0\"></a>&nbsp;&nbsp;
                  <a href=\"banner.php?op=delete_client&idclient=$idclient\" onclick='return confirm(\"Sei sicuro di voler eliminare questo Cliente? \")'><img src=\"imgs/ico_delete.gif\" width=16 height=16 alt=\"cancella\" title=\"cancella\" border=\"0\"></a>";                 
				  $content .= "<tr>
				  				<td class=\"tbtit\" align=\"center\" width=\"10%\"><b>$i</b></td>
				 				<td class=tdelenco align=center>&nbsp;".$client->nome."</td>
								<td class=tdelenco>&nbsp;".$client->contatto."</td>
								<td class=tdelenco align=center>&nbsp;".$client->mail."</td>
								<td class=tdelenco align=center>&nbsp;".$client->telefono."</td>
								<td align=\"center\" valign=\"middle\" class=tdelenco>
								 $azioni";
                 $content .= "</td>
				 </tr>\n";
				 $rs->MoveNext();
				 $i++;
               }
				 $rs->Close();
				 $r_tot->Close();
               //$content .= "</table>\n";
               //inizio paginazione
                     $content .= "<tr><td colspan=6><table class=\"tbtit\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\n";
                     $num_pages = ($num_user/$num_per_page) + 1;
                     $resto =  $num_user%$num_per_page;
                     if ($resto==0)
                      $num_pages--;
                     $content .= "<tr><td align=\"left\">";
                     if ($min!=0)   {
                      $min1 = $min-$num_per_page;
                      $max1 = $max-$num_per_page;
                      if ($page!=1)
                       $page1 = $page-1;;
                      $content .= "<a href=\"banner.php?op=all_client&min=$min1&max=$num_per_page&page=$page1\"><img src=\"imgs/precedente.gif\" border=\"0\" alt=\"precedente\"></a>&nbsp;&nbsp;&nbsp;";
                      }
                      $content .= "</td><td align=\"center\">
					  #&nbsp;<input type=text name=num_per_page value=\"$num_per_page\" onBlur=\"javascript:doReload(this.value);\" size=3 maxlength=3>&nbsp;&nbsp;";
                     for ($i=1;$i<=$num_pages;$i++)  {
                       if ($page!=$i)  {
                        $max1 = $i*$num_per_page;
                        $min1 = $max1 - $num_per_page;
                        $content .= "<a href=\"banner.php?op=all_client&min=$min1&max=$num_per_page&page=$i\"><b>$i</b></a>";
                        $content .= "  ";
                       }  else
                         $content .= "  $i  ";
                     }
                     $content .= "</td><td align=\"right\">";
                     $diff2 = $num_user - ($num_per_page*$page);
                     if ($diff2 > 0)   {
                      $min1 = $min + $num_per_page;
                      $max1 = $max + $num_per_page;
                      $page1 = $page + 1;
                      $content .= "&nbsp;&nbsp;&nbsp;<a href=\"banner.php?op=all_client&min=$min1&max=$num_per_page&page=$page1\"><img src=\"imgs/successivo.gif\" border=\"0\" alt=\"successivo\"></a>";
                     }
                     $content .= "</td></tr></table>\n";
					}
					 $content .= "</td></tr>
					 <tr>
					  <td colspan=6>&nbsp;</td>
					 </tr>
					 <tr>
					  <td colspan=6 align=center>
					   <table width=450 class=content cellpadding=2 bgcolor=#CCCCCC>
					    <form action=banner.php method=POST>
					    <tr>
						 <td width=200 align=right>Ricerca per nome o e-mail:</td>
						 <td width=150><input type=text name=search size=30></td>
						 <td><input type=hidden name=op value=search_client><input type=submit value=Cerca></td>
						</tr>
						</form>
					   </table>
					  </td>
					 </tr>
					 <tr>
					  <td colspan=6>&nbsp;</td>
					 </tr>
					 </table>\n";
			  break;

              case "add_client":
				     $content = "<table width=100% cellpadding=3 cellspacing=0 class=content border=\"1 solid #COCOCO\">
				   			<form name=\"insertclient\" action=\"banner.php\" method=\"POST\">
				   	<tr><td align=\"center\" class=tbtit colspan=2><b>Aggiungi Cliente</b></td></tr>
					<tr>
					 <td align=right><b>Nome:</b></td><td><input type=\"text\" name=\"nome\" size=30/></td>
				   </tr>
                   <tr>
				    <td align=right><b>Contatto:</b></td><td><input type=\"text\" name=\"contatto\" size=\"30\" /></td>
					</tr>
                  <tr>
				    <td align=right><b>E-mail:</b></td><td><input type=\"text\" name=\"mail\" size=\"30\" /></td>
					</tr>
                   <tr>
				    <td align=right><b>Telefono:</b></td><td><input type=\"text\" name=\"telefono\" size=\"30\" /></td>
					</tr>
					<tr>
					  <td align=center colspan=2>
					   <input type=\"hidden\" name=\"op\" value=\"save_client\" />
                   	   <input type=\"image\" src=\"imgs/ico_save.gif\" title=\"Aggiungi\"/ onclick=\"return control_client();\"> - <a href=\"javascript:document.insertclient.submit();\" onclick=\"return control_client();\">Salva</a></td></tr></form>
				   </table>";
              break;

              case "save_client":
				   $nome = $_POST['nome'];
				   $contatto = $_POST['contatto'];
				   $mail = $_POST['mail'];
				   $telefono = $_POST['telefono'];
					   $newClient = new bannerClient();
					   $error = $newClient->save($nome,$contatto,$mail,$telefono);
					   if ($error == "0")  {
						Header("Location:banner.php?op=all_client");
					   }  else  {
						$content = printError($error);
					   }
              break;	

              case "mod_client":
			  	     $idclient = $_GET['idclient'];
					 $client = new bannerClient($idclient);
				     $content = "<table width=100% cellpadding=3 cellspacing=0 class=content border=\"1 solid #COCOCO\">
				   			<form name=\"insertclient\" action=\"banner.php\" method=\"POST\">
				   	<tr><td align=\"center\" class=tbtit colspan=2><b>Modifica Cliente</b></td></tr>
					<tr>
					 <td align=right><b>Nome:</b></td><td><input type=\"text\" name=\"nome\" size=30 value=\"".$client->nome."\"></td>
				   </tr>
                   <tr>
				    <td align=right><b>Contatto:</b></td><td><input type=\"text\" name=\"contatto\" size=\"30\" value=\"".$client->contatto."\"></td>
					</tr>
                  <tr>
				    <td align=right><b>E-mail:</b></td><td><input type=\"text\" name=\"mail\" size=\"30\" value=\"".$client->mail."\"></td>
					</tr>
                   <tr>
				    <td align=right><b>Telefono:</b></td><td><input type=\"text\" name=\"telefono\" size=\"30\" value=\"".$client->telefono."\"></td>
					</tr>
					<tr>
					  <td align=center colspan=2>
					   <input type=\"hidden\" name=\"op\" value=\"update_client\" />
					   <input type=\"hidden\" name=\"idclient\" value=\"$idclient\" />
                   	   <input type=\"image\" src=\"imgs/ico_save.gif\" title=\"Aggiungi\"/ onclick=\"return control_client();\"> - <a href=\"javascript:document.insertclient.submit();\" onclick=\"return control_client();\">Salva</a></td></tr></form>
				   </table>";
              break;

              case "update_client":
			  	   $idclient = $_POST['idclient'];
				   $nome = $_POST['nome'];
				   $contatto = $_POST['contatto'];
				   $nick = $_POST['nick'];
				   $mail = $_POST['mail'];
				   $telefono = $_POST['telefono'];
				   $newClient = new bannerClient($idclient);
				   $error = $newClient->update($nome,$contatto,$mail,$telefono);
				   $content = printError($error,"banner.php?op=all_client");
              break;

              case "delete_client":
			  	   $idclient = $_GET['idclient'];
				   $newClient = new bannerClient($idclient);
				   $error = $newClient->delete();
				   $content = printError($error,"banner.php?op=all_client");
              break;

			  case "search_client":
			    $content = bannerClient::search($search);
			  break;
			  
			  case "del_prom":
				$idarticolo = $_GET['idarticolo'];
				$idbanner = $_GET['idbanner'];
				//$newBanner = new banner($idbanner);
				banner::delArticoloPromo($idbanner,$idarticolo);
				//die($newBanner->getPromozioni(2));
				header("Location: banner.php?op=mod&idbanner=$idbanner");
				die();
				break;
				
			case "svuota_prom":
				$idbanner = $_GET['idbanner'];
				banner::svuotaPromo($idbanner);
				//die($newBanner->getPromozioni(2));
				header("Location: banner.php?op=mod&idbanner=$idbanner");
				die();
				break;
					
			case "add_prom":
				$cid = $_GET['cid'];
				$idarticolo = $_GET['idarticolo'];
				$idbanner = $_GET['idbanner'];
				//$newBanner = new banner($idbanner);
				banner::addArticoloPromo($idbanner,$idarticolo,$cid);
				//die($newBanner->getPromozioni(2));
				header("Location: banner.php?op=mod&idbanner=$idbanner");
				die();
				break;

			  default:
			   $content = "&nbsp;";
			  break;
              }
       break;

       case AUTH_NOT_LOGGED:
        header("Location:index.html");
       break;
}
?>
<html>
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Modulo Banner</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<link rel="stylesheet" type="text/css" media="all" href="skins/aqua/theme.css" title="Aqua">
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="calendar-it.js"></script>
<script language="javascript">

function control_client()  {
   if(document.insertclient.nome.value=="")  {
     alert('Devi inserire il nome!');
     return false;
   }
   if(document.insertclient.mail.value=="")  {
     alert('Devi inserire l\'indirizzo e-mail!');
     return false;
   }
   if(document.insertclient.telefono.value=="")  {
     alert('Devi inserire il telefono');
     return false;
   }
}

function control_banner()  {
   if(document.insertbanner.posizione.selectedIndex == 0)  {
     alert('Devi selezionare la posizione!');
     return false;
   }
   if(document.insertbanner.ordine.selectedIndex == 0)  {
     alert('Devi selezionare l\'ordine!');
     return false;
   }
   if(document.insertbanner.imptotal.value == "0" && (document.insertbanner.startDate.value == "" || document.insertbanner.endDate.value == ""))  {
     alert('Devi selezionare e impostare una scadenza');
     return false;
   }
}

function doSwitchScadenza(radio)  {
	  var form = document.insertbanner;
	  var link1 = document.getElementById("link1");
	  var link2 = document.getElementById("link2");
	if(radio.value == 'date')  {
	  form.startDate.disabled = false;
	  form.endDate.disabled = false;
	  form.imptotal.value = '0';
	  form.imptotal.disabled = true;
	  link1.onclick = function()  {
	  		  id = 'data1';
			  format = '%d/%m/%Y';
			  showsOtherMonths = '';
			  var el = document.getElementById(id);
			  if (_dynarch_popupCalendar != null) {
				// we already have some calendar created
				_dynarch_popupCalendar.hide();                 // so we hide it first.
			  } else {
				// first-time call, create the calendar.
				var cal = new Calendar(1, null, selected, closeHandler);
				// uncomment the following line to hide the week numbers
				// cal.weekNumbers = false;
				if (typeof showsTime == "string") {
				  cal.showsTime = true;
				  cal.time24 = (showsTime == "24");
				}
				if (showsOtherMonths) {
				  cal.showsOtherMonths = true;
				}
				_dynarch_popupCalendar = cal;                  // remember it in the global var
				cal.setRange(1900, 2070);        // min/max year allowed.
				cal.create();
			  }
			  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
			  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
			  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
			  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
			
			  return false;	  
	  };
	  link2.onclick = function()  {
	  		  id = 'data2';
			  format = '%d/%m/%Y';
			  var el = document.getElementById(id);
			  if (_dynarch_popupCalendar != null) {
				// we already have some calendar created
				_dynarch_popupCalendar.hide();                 // so we hide it first.
			  } else {
				// first-time call, create the calendar.
				var cal = new Calendar(1, null, selected, closeHandler);
				// uncomment the following line to hide the week numbers
				// cal.weekNumbers = false;
				if (typeof showsTime == "string") {
				  cal.showsTime = true;
				  cal.time24 = (showsTime == "24");
				}
				if (showsOtherMonths) {
				  cal.showsOtherMonths = true;
				}
				_dynarch_popupCalendar = cal;                  // remember it in the global var
				cal.setRange(1900, 2070);        // min/max year allowed.
				cal.create();
			  }
			  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
			  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
			  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
			  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
			
			  return false;	  
	  };
	} else {
	  form.startDate.value = ' ';
	  form.endDate.value = ' ';
	  form.startDate.disabled = true;
	  form.endDate.disabled = true;
	  form.imptotal.disabled = false;
	  link1.onclick = function(){};
	  link2.onclick = function(){};	 
	}
}

function RicaricaOrdine(){
		var config = new Array();
<?
	$array = "config['destra'] = ".$_CONFIG['num_destra']."\n";
	$array .= "config['sinistra'] = ".$_CONFIG['num_sinistra']."\n";
	echo $array;
?>
		config['alto'] = 1;
		config['basso'] = 1;
        valore = document.insertbanner.posizione[document.insertbanner.posizione.selectedIndex].value;
        if (valore!='ALL'){
            for (var i = document.insertbanner.ordine.length; i>=0  ; i--) {
                document.insertbanner.ordine.options[i] = null;
            }
            document.insertbanner.ordine.options[0]=new Option('Seleziona','');
            for (i=1;i<=config[valore];i++){
                document.insertbanner.ordine.options[i]=new Option(i,i);
            }
        }
    }

function showHide(id,i)  {
	var obj;
	obj=MM_findObj(id);
	if(obj.style.visibility=='visible') {
	 MM_showHideLayers(id,'','hide');
	 var image = MM_findObj('apri'+i);
	 image.src = 'imgs/apri.jpg';
	} else  {
	 MM_showHideLayers(id,'','show');
	 var image = MM_findObj('apri'+i);
	 image.src = 'imgs/chiudi.jpg';
	}
}

function doReload(num)  {
  if(num >= 10 && !isNaN(num))  {
    document.location.href = 'banner.php?op=all&num_per_page=' + num; 
  }
}

var oldLink = null;

function setActiveStyleSheet(link, title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (oldLink) oldLink.style.fontWeight = 'normal';
  oldLink = link;
  link.style.fontWeight = 'bold';
  return false;
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    cal.callCloseHandler();
}

function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

function isDisabled(date) {
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}

function flatSelected(cal, date) {
  var el = document.getElementById("preview");
  el.innerHTML = date;
}

function showFlatCalendar() {
  var parent = document.getElementById("display");

  var cal = new Calendar(0, null, flatSelected);

  cal.weekNumbers = false;

  cal.setDisabledHandler(isDisabled);
  cal.setDateFormat("%A, %B %e");

  cal.create(parent);

  cal.show();
}

function check_date(field){

var checkstr = "0123456789";

var DateField = field;

var Datevalue = "";

var DateTemp = "";

var seperator = "/";

var day;

var month;

var year;

var step = 0;

var err = 0;

var i;

   err = 0;

   DateValue = DateField.value;

   /* cancello tutti i dati tranne 0-9 */

   for (i = 0; i < DateValue.length; i++) {

              if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {

                 DateTemp = DateTemp + DateValue.substr(i,1);

              }

   }

   DateValue = DateTemp;

  /* se l'anno � inserito con 2 valori lo cambio sempre con  20xx */

   if (DateValue.length == 6) {

      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }

   if (DateValue.length != 8) {

      err = 19;}

   /* anno sbagliato 0000 */

   year = DateValue.substr(4,4);

   if (year == 0) {

      err = 20;

   }

   /* validazione del mese*/

   month = DateValue.substr(2,2);

   if ((month < 1) || (month > 12)) {

      err = 21;

   }

   /* validazione del giorno */

   day = DateValue.substr(0,2);

   if (day < 1) {

     err = 22;

   }

   /* Validazione anno / febbraio / gg */

   if ((year % 4 == 0)) {

      step = 1;

   }

   if ((month == 2) && (step == 1) && (day > 29)) {

      err = 23;

   }

   if ((month == 2) && (step != 1) && (day > 28)) {

      err = 24;

   }

   /* validazione dei mesi */

   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {

      err = 25;

   }

   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {

      err = 26;

   }

   /* se � inserito 00 cancello i dati */

   if ((day == 0) && (month == 0) && (year == 00)) {

      err = 0; day = ""; month = ""; year = ""; seperator = "";

   }

   /* Se non ci sono errori inserisco la data (esempio 13.12.2001) */

   if (err == 0) {

      DateField.value = day + seperator + month + seperator + year;

   }

   /* Messaggio di errore, avviso di data corretta se err diverso da 0 */

   else {
alert('La data inserita non e\' corretta.Il formato corretto e\': dd/mm/yyyy  dd/mm/yy');

      DateField.select();

              DateField.focus();

   }

}
</script>

<!-- InstanceEndEditable -->
<link href="style/style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="javascript" src="js/banner.js"></script>
<script type="text/JavaScript">

<?=$javascript?>

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  var dis;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) {
	   obj=obj.style; 
	   if(v == 'show')  {
	     v = 'visible';
		 dis = 'block';
	   }
	   if(v == 'hide')  {
	     v = 'hidden';
		 dis = 'none';	 
	   }
	 }  
    obj.visibility = v; 
	obj.display = dis;
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="<?=$onload?>">
<!-- ImageReady Slices (gestione.psd - Slices: 02, 03, 04, 06, 07, 08, 09, 10, 11, 12) -->
<!-- End ImageReady Slices -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40" height="177" background="imgs/bkgSx.gif">&nbsp;</td>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="552" background="imgs/gestione_02.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="360"><img src="imgs/spacer20.gif" width="360" height="73"></td>
            <td><table width="100%" height="73" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="5"><img src="imgs/spacer20.gif" width="45" height="5"></td>
              </tr>
              <tr>
                <td align="left" valign="middle" class="tit01"><!-- InstanceBeginEditable name="user" --><?=$username?><!-- InstanceEndEditable --></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
        <td background="imgs/gestione_03.gif">&nbsp;</td>
        <td width="221"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="imgs/gestione_04.gif" width="221" height="17" alt=""></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="57"><a href="gestione.php?logout=1"><img src="imgs/gestione_06.gif" alt="Logout" width="57" height="51" border="0"></a></td>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><a href="mailto:info@media-tek.it"><img src="imgs/gestione_07.gif" alt="" width="164" height="25" border="0"></a></td>
                  </tr>
                  <tr>
                    <td><a href="#"><img src="imgs/gestione_08.gif" alt="" width="164" height="26" border="0"></a></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><img src="imgs/gestione_09.gif" width="221" height="5" alt=""></td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="100%" height="104" border="0" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="678" background="imgs/gestione_10.gif">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="203">
						<table width="203" height="104" border="0" cellpadding="0"
							cellspacing="0">
							<tr>
								<td><img src="imgs/spacer20.gif" width="203" height="65"></td>
							</tr>
							<tr>
								<td>
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="45"><img src="imgs/spacer20.gif" width="45"
											height="39"></td>
										<td>
										<table width="100%" height="39" border="0" cellpadding="5"
											cellspacing="0">
											<tr>
												<td align="left" valign="middle" class="module"><?=$module?>
												</td>
											</tr>
										</table>
										</td>
									</tr>
								</table>
								</td>
							</tr>
						</table>
						</td>
						<td>
						<table width="475" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="50"><img src="imgs/spacer20.gif" width="50"
									height="104" alt=""></td>
								<td align="left" valign="bottom"><? if($level!="VBL")  { ?>
								<table border="0" cellspacing="0" cellpadding="2">
									<tr>
									<?
									if($level=="admin")  {
										?>
										<td width="58"><a href="gestione.php?module=content"
											onMouseOut="MM_swapImgRestore()"
											onMouseOver="MM_swapImage('pages','','imgs/icons/pag_web-b.gif',1)"><img
											src="imgs/icons/pag_web.gif" alt="Pagine web" name="pages"
											width="58" height="69" border="0"></a></td>
										<td width="58"><a href="gestione.php?module=newsletter"
											onMouseOut="MM_swapImgRestore()"
											onMouseOver="MM_swapImage('Newsletter','','imgs/icons/newsletter-b.gif',1)"><img
											src="imgs/icons/newsletter.gif" alt="Newsletter"
											name="Newsletter" width="58" height="69" border="0"></a></td>
											<?
									}
									?>
										<td width="58"><a href="gestione.php?module=banner"
											onMouseOut="MM_swapImgRestore()"
											onMouseOver="MM_swapImage('banner','','imgs/icons/gest_banner-b.gif',1)"><img
											src="imgs/icons/gest_banner.gif" alt="Gestione Banner"
											name="banner" width="58" height="69" border="0"></a></td>
										<td width="58"><a href="gestione.php?module=prodotti"><img
											src="imgs/icons/prodotti.gif" alt="Pagine Web" name="pagine"
											width="58" height="69" border="0" id="pagine"
											onMouseOver="MM_swapImage('pagine','','imgs/icons/prodotti-b.gif',1)"
											onMouseOut="MM_swapImgRestore()"></a></td>
									</tr>
								</table>
								<? } ?></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
				<td valign="bottom" background="imgs/gestione_11.gif">
				<table cellpadding="2" cellspacing="0">
					<tr>
						<td width="58"><a href="gestione.php?module=webuser"
							onMouseOut="MM_swapImgRestore()"
							onMouseOver="MM_swapImage('webutente','','imgs/icons/utenti-b.gif',1)"><img
							src="imgs/icons/utenti.gif" name="webutente" width="58"
							height="69" border="0"></a></td>
							<?
				if($level=="admin")  {
					?>
						<td width="58"><a href="gestione.php?module=user"
							onMouseOut="MM_swapImgRestore()"
							onMouseOver="MM_swapImage('Utente','','imgs/icons/info_utente-b.gif',1)"><img
							src="imgs/icons/info_utente.gif" name="Utente" width="58"
							height="69" border="0"></a></td>
						
				<?
				} else {
					?>&nbsp;<?
				}
				?>
						<td width="20" valign="middle">
						</td>
					</tr>
				</table>
				</td>
				<td width="95"><img src="imgs/gestione_12.gif" width="95"
					height="104" alt=""></td>
			</tr>
		</table>
    </td>
    <td width="40" background="imgs/bkgDx.gif">&nbsp;</td>
  </tr>
  <tr>
    <td background="imgs/bkgSx.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F6F6F6"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="203" align="left" valign="top" bgcolor="#DFDFDF" class="menusx"><!-- InstanceBeginEditable name="menuSx" --><?=$menusx?><!-- InstanceEndEditable --></td>
        <td align="left" valign="top" bgcolor="#EFEFEF" class="content"><!-- InstanceBeginEditable name="content" --><?=$content?><!-- InstanceEndEditable --></td>
      </tr>
    </table>
      <table width="100%" height="50" border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td background="imgs/gestione_03.gif" bgcolor="#F6F6F6" class="copy"><p>2006&copy; Gestione moduli dinamici - release 1.2 - Powered by Media-tek </p></td>
        </tr>
      </table></td>
    <td background="imgs/bkgDx.gif">&nbsp;</td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>